//
//  HXItemFenbaoMessageTableViewCell.m
//  KD
//
//  Created by ifly on 16/6/6.
//  Copyright © 2016年 Whx. All rights reserved.
//

#import "HXItemFenbaoMessageTableViewCell.h"
#import "HXCropMessageBackgroundView.h"

@interface HXItemFenbaoMessageTableViewCell()
@property (weak, nonatomic) IBOutlet UILabel *corpLabel;
@property (weak, nonatomic) IBOutlet UILabel *personLabel;//项目经理
@property (weak, nonatomic) IBOutlet UILabel *personPhoneLabel;
@property (weak, nonatomic) IBOutlet UILabel *isQingLabel;
@property (weak, nonatomic) IBOutlet UILabel *gradeLabel;
@property (weak, nonatomic) IBOutlet UILabel *moneyLabel;
@property (weak, nonatomic) IBOutlet UILabel *fanWeiLabel;
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UIButton *projectMemberBtn;//项目班子成员

@property (nonatomic,strong) NSMutableArray <HXGetProjectMemberDetailModel *>* dataArr;
@property (nonatomic,strong) NSMutableArray <HXGetChickUpHistoryDetailModel *>* historyDataArray;

@end

@implementation HXItemFenbaoMessageTableViewCell
- (IBAction)projectMemberBtn:(UIButton *)sender {
    
    [self getDate];
    
}
- (IBAction)chickUpHistoryBtn:(UIButton *)sender {
    
    [self getHistoryData];
}

/**
 查询历史
 */
-(void)getHistoryData {
    
    _historyDataArray = [NSMutableArray array];
    [SVProgressHUD showWithStatus:@"正在加载"];
    
    [NetworkAPI getChickUpHistroyWithKeyGuid:_data.KeyGuid
                                     Success:^(HXGetChickUpHistoryModel *result) {
                                         if ([result.code isEqualToString:@"200"]) {
                                             [self.historyDataArray addObjectsFromArray:result.resultlist];
                                             [SVProgressHUD showSuccessWithStatus:@"加载成功"];
                                             
                                             HXCropMessageBackgroundView * bgView = [[HXCropMessageBackgroundView alloc]
                                                                                     initWithFrame:CGRectMake(0, 0, HXSCREEN_WIDTH, HXSCREEN_HEIGHT) withHistoryType:ChickUpHistoryType];
                                             bgView.chickUpHistoryArr = self.historyDataArray;
                                             [bgView showView];
                                             
                                         }
                                         else if ([result.code isEqualToString:@"400"]) {
                                             
                                             [SVProgressHUD showErrorWithStatus:@"请求失败,请重新尝试"];
                                             
                                         }else {
                                             
                                             [SVProgressHUD showErrorWithStatus:@"暂无数据"];
                                         }
                                     } failure:^(NSError *err) {
                                         [SVProgressHUD showErrorWithStatus:@"网络请求错误"];
                                     }];
    
    
}






/**
 请求数据
 */
-(void)getDate{
    
    _dataArr = [NSMutableArray array];
    
    [SVProgressHUD showWithStatus:@"正在加载"];
    [NetworkAPI getProjectMemberWithCorpType:@"-1"
                                      PrjNum:@""
                                     KeyGuid:_data.KeyGuid
                                    CorpCode:_data.CorpCode
                                     Success:^(HXGetProjectMemberModel *result) {
                                         if ([result.code isEqualToString:@"200"]) {
                                             
                                             [self.dataArr addObjectsFromArray:result.result];
                                             [SVProgressHUD showSuccessWithStatus:@"加载成功"];
                                             
                                             HXCropMessageBackgroundView * bgView = [[HXCropMessageBackgroundView alloc]
                                                                                     initWithFrame:CGRectMake(0, 0, HXSCREEN_WIDTH, HXSCREEN_HEIGHT) withHistoryType:ProjectHistoryType];                                             
                                             //                                             HXCropMessageBackgroundView * bgView = [[HXCropMessageBackgroundView alloc]
                                             //                                                                                     initWithFrame:CGRectMake(0, 0, HXSCREEN_WIDTH, HXSCREEN_HEIGHT)
                                             //                                                                                     withCorpType:_data.CorpType
                                             //                                                                                     withPrjNum:_sendModelStr
                                             //                                                                                     withKeyGuid:@""];
                                             
                                             bgView.dataArray = self.dataArr;
                                             
                                             [bgView showView];
                                             
                                         }
                                         else if ([result.code isEqualToString:@"400"]) {
                                             
                                             [SVProgressHUD showErrorWithStatus:@"请求失败,请重新尝试"];
                                             
                                         }else {
                                             
                                             [SVProgressHUD showErrorWithStatus:@"暂无数据"];
                                             
                                         }
                                     } failure:^(NSError *err) {
                                         [SVProgressHUD showErrorWithStatus:@"网络请求错误"];
                                         
                                     }];
    
}



- (void)setData:(HXFenBaoMessageDetailsListArrayModel *)data{
    _data = data;
    
    NSLog(@"_data----------------%@",self.data);
    
    if ([GlobalUtil isNilValue:_data.ContractorCorpName]) {
        self.corpLabel.text = @"暂无";
    }else{
        self.corpLabel.text = _data.ContractorCorpName;
    }
    if ([GlobalUtil isNilValue:_data.ManagerName]) {
        self.personLabel.text = @"暂无";
    }else{
        self.personLabel.text = _data.ManagerName;
    }
    if ([GlobalUtil isNilValue:_data.ManagerTel]) {
        self.personPhoneLabel.text = @"暂无";
    }else{
        self.personPhoneLabel.text = _data.ManagerTel;
    }
    if ([GlobalUtil isNilValue:_data.IsQDAssessment]) {
        self.isQingLabel.text = @"暂无";
    }else{
        self.isQingLabel.text = _data.IsQDAssessment;
    }
    if ([GlobalUtil isNilValue:_data.QualificationLevOfContractor]) {
        self.gradeLabel.text = @"暂无";
    }else{
        self.gradeLabel.text = _data.QualificationLevOfContractor;
    }
    if ([GlobalUtil isNilValue:_data.ContractMoney]) {
        self.moneyLabel.text = @"暂无";
    }else{
        self.moneyLabel.text = _data.ContractMoney;
    }
    if ([GlobalUtil isNilValue:_data.ContractScope]) {
        self.fanWeiLabel.text = @"暂无";
    }else{
        self.fanWeiLabel.text = _data.ContractScope;
    }
    if ([GlobalUtil isNilValue:_data.CreateDate]) {
        self.dateLabel.text = @"暂无";
    }else{
        self.dateLabel.text = _data.CreateDate;
    }
   
}



@end
